package com.atguigu.rabbitmq.six;

import com.atguigu.rabbitmq.utils.RabbitMqutils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ReceiveLogsDirect02 {


    public static final String EXCHANGE_NAME="direct_logs";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqutils.getChannel();

        //声明一个交换机
        /**
         * 1.交换机的名字
         * 2.类型 fanout 主要练习的就是他
         */
        channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.FANOUT);
        //声明一个队列
        channel.queueDeclare("disk",false,false,false,null);

        channel.queueBind("disk",EXCHANGE_NAME,"error");


        //接受消息
        DeliverCallback deliverCallback = (var1, var2) ->
        {

            System.out.println("ReceiveLogsDirect02控制台打印接口道的消息：-[]" + new String(var2.getBody(), "utf-8"));
        };


        //消费者取消消息时回调的接口
        channel.basicConsume("disk", true, deliverCallback, var1 -> {
        }, null);


    }



}
